﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:p="clr-namespace:Lithnet.Acma.Presentation"
                    xmlns:a="clr-namespace:Lithnet.Acma;assembly=Lithnet.Acma"
                    xmlns:fim="clr-namespace:Microsoft.MetadirectoryServices;assembly=Microsoft.MetadirectoryServicesEx"
                    xmlns:core="clr-namespace:Lithnet.Common.Presentation;assembly=Lithnet.Common.Presentation">

    <DataTemplate  DataType="{x:Type p:UniqueValueConstructorViewModel}">
        <StackPanel>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="150" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <TextBlock Text="Ordered list of declarations to try"
                           Grid.Row="0"
                           Grid.Column="0"
                           Margin="2"
                           TextWrapping="Wrap" />

                <DataGrid AutoGenerateColumns="False"
                          HorizontalAlignment="Stretch"
                          VerticalAlignment="Stretch"
                          ItemsSource="{Binding Path=ValueDeclarationBindingList, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                          Grid.Row="0"
                          Grid.Column="1"
                          CanUserAddRows="true"
                          CanUserDeleteRows="true"
                          Height="200"
                          Margin="2">
                    <DataGrid.Columns>
                        <DataGridTemplateColumn Header="Declaration"
                                                Width="Auto">
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <p:DeclarationEditBox Text="{Binding Path=Declaration, Mode=TwoWay, UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                                                          DeclarationMode="ComplexAttributeDeclaration"
                                                          ObjectClass="{Binding Path=ObjectClass, Mode=OneWay}"
                                                          SyntaxErrors="{Binding Path=SyntaxErrors, Mode=OneWayToSource}"
                                                          IsMultiLine="True"
                                                          Margin="1" />
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <p:DeclarationEditBox Text="{Binding Path=Declaration, Mode=OneWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                                                          DeclarationMode="ComplexAttributeDeclaration"
                                                          ObjectClass="{Binding Path=ObjectClass, Mode=OneWay}"
                                                          IsMultiLine="True"
                                                          Margin="1" />
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Header="Transforms"
                                                Width="Auto">
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <p:TransformEditBox Text="{Binding Path=TransformsString, 
                                        Mode=TwoWay,
                                        UpdateSourceTrigger=LostFocus,
                                        ValidatesOnDataErrors=True, 
                                        ValidatesOnExceptions=true}"
                                                        Margin="1"
                                                        IsMultiLine="False" />
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <p:TransformEditBox Text="{Binding Path=TransformsString, Mode=TwoWay, UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                                                        Margin="1"
                                                        IsMultiLine="False" />
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                    </DataGrid.Columns>
                </DataGrid>

                <TextBlock Text="Unique fall-back value (must include %o% or %n%)"
                           Grid.Row="1"
                           Grid.Column="0"
                           Margin="2"
                           TextWrapping="Wrap" />

                <Grid Grid.Row="1"
                      Grid.Column="1">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Border Grid.Row="0"
                            Grid.Column="0"
                            CornerRadius="0"
                            Padding="2"
                            Margin="2"
                            BorderThickness="1"
                            BorderBrush="Black">

                        <p:DeclarationEditBox Text="{Binding Path=DeclarationString, Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                                              DeclarationMode="UniqueAttributeDeclaration"
                                              ObjectClass="{Binding Path=ObjectClass, Mode=OneWay}"
                                              SyntaxErrors="{Binding Path=SyntaxErrors, Mode=OneWayToSource}"
                                              Margin="1" />
                    </Border>
                    <Label Content="Transforms"
                           Grid.Row="0"
                           Grid.Column="1"
                           Margin="2" />
                    <Border Grid.Row="0"
                            Grid.Column="2"
                            CornerRadius="0"
                            Padding="2"
                            Margin="2"
                            BorderThickness="1"
                            BorderBrush="Black">
                        <p:TransformEditBox Text="{Binding Path=TransformsString, Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                                            Margin="1" />
                    </Border>
                </Grid>

                <Grid Grid.Row="3"
                      Grid.ColumnSpan="2">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition MaxWidth="40" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <TextBlock Text="Available attributes"
                               Grid.Row="0"
                               Grid.Column="0"
                               Margin="2"
                               TextWrapping="Wrap" />

                    <TextBlock Text="Selected attributes"
                               Grid.Row="0"
                               Grid.Column="2"
                               Margin="2"
                               TextWrapping="Wrap" />

                    <ListBox ItemsSource="{Binding Path=AllowedUniqueAllocationAttributes,Mode=OneWay}"
                             DisplayMemberPath="Name"
                             Grid.Row="1"
                             Grid.Column="0"
                             MaxHeight="150"
                             ScrollViewer.VerticalScrollBarVisibility="Auto"
                             Margin="2">
                        <ListBox.Resources>

                            <Style TargetType="{x:Type ListBoxItem}">
                                <Setter Property="IsSelected"
                                        Value="{Binding Path=IsSelected, Mode=TwoWay}" />
                            </Style>
                        </ListBox.Resources>
                    </ListBox>

                    <StackPanel Grid.Row="1"
                                Grid.Column="1"
                                Margin="5,0,5,0">
                        <Button Content="&gt;"
                                Command="{Binding Path=Commands.Add}" />
                        <Button Content="&lt;"
                                Command="{Binding Path=Commands.Remove}" />
                    </StackPanel>

                    <ListBox ItemsSource="{Binding Path=UniqueAllocationAttributes,Mode=OneWay}"
                             DisplayMemberPath="Name"
                             Grid.Row="1"
                             Grid.Column="2"
                             MaxHeight="150"
                             ScrollViewer.VerticalScrollBarVisibility="Auto"
                             Margin="2">
                        <ListBox.Resources>

                            <Style TargetType="{x:Type ListBoxItem}">
                                <Setter Property="IsSelected"
                                        Value="{Binding Path=IsSelected, Mode=TwoWay}" />
                            </Style>
                        </ListBox.Resources>
                    </ListBox>

                    <TextBlock Visibility="{Binding Path=IsMissingIndex, Converter={StaticResource BooleanToVisibilityConverter}}"
                               Text="{Binding Path=MissingIndexMessage}"
                               Grid.Row="2"
                               Grid.ColumnSpan="2"
                               Margin="3,3,3,3" />
                </Grid>

            </Grid>
        </StackPanel>
    </DataTemplate>

</ResourceDictionary>